package look4ss.aplicativo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.github.chrisbanes.photoview.PhotoView;
import com.sdsmdg.tastytoast.TastyToast;
import com.squareup.picasso.Picasso;

public class ActivityImagem extends AppCompatActivity {
    private PhotoView ImagemLugar;
    private ProgressBar barraDeLoading;
    public static String imagem = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_imagem);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        ImagemLugar = findViewById(R.id.imagemFull);
        barraDeLoading = findViewById(R.id.imagemCarregando);
        carregarImagem();
    }

    private void carregarImagem() {
        Picasso.get().load(imagem).into(ImagemLugar, new com.squareup.picasso.Callback() {
            public void onSuccess() {
                barraDeLoading.setVisibility(View.GONE);
            }
            public void onError(Exception ex) {
                TastyToast.makeText(ActivityImagem.this, getString(R.string.erro_carregar_imagem), Toast.LENGTH_LONG, TastyToast.ERROR);
                barraDeLoading.setVisibility(View.GONE);
            }
        });
    }
}
